# (HRM) E:\hrManageVD\hrManageDjango>
# 切记切记，多次踩坑，在这个路径下执行这个命令，指定task文件
# celery -A celery_task.celery_sms worker -l info -P eventlet

from .celery import app
import sys
from ronglian_sms_sdk import SmsSDK
from FSJY.libs.sendSms import sms_settings,get_random_code
from FSJY.utils.logger import log
from FSJY.utils.buyHighResponse import APIResponse
@app.task
def celery_send_message(tid,mobile,datas):
    """
        tid = '容联云通讯创建的模板ID'
        mobile = '手机号1,手机号2'
        datas = ('变量1', '变量2)
    """
    sdk = SmsSDK(sms_settings.accId, sms_settings.accToken, sms_settings.appId)
    try:
        result=sdk.sendMessage(tid, mobile, datas)
        print("成功执行任务")
        print(result)
        return result
    except Exception as e:
        print(str(e))
        log.error("手机号:%s,短信发送失败，错误为%s"%(mobile,str(e)))
        # print(str(e))